#include "boss.h"
#include <shuju.h>

boss::boss()
{
    Boss.load(":/pic/res/boss.png");
    //飞机坐标；
    x = (sence_w-Boss.width())*0.5;
    y = 0;
    b_Rect.setWidth(Boss.width());
    b_Rect.setHeight(Boss.height());
    b_Rect.moveTo(x , y);
    blood = 10000 ;
    left = 1;
    rigte = 0;
}

void boss::shoot()
{
    //子弹1时间间隔
    recode1++;
    if(recode1 < 100)
    {
        return;
    }
   //可发射时
    recode1 = 0;
    for(int i = 0; i < 30;i++)
    {
        if(bullets1[i].b_free == 1)
        {
            bullets1[i].b_free = 0;
            //子弹位置
            bullets1[i].b_x = x + b_Rect.width()*0.5+30;
            bullets1[i].b_y = y + b_Rect.height();
            break;
        }
    }

    for(int i = 0; i < 5;i++)
    {
        if(bullets2[i].b_free == 1)
        {
            bullets2[i].b_free = 0;
            //子弹位置
            bullets2[i].b_x = x + b_Rect.width()*0.5 ;
            bullets2[i].b_y = y + b_Rect.height();
            break;
        }
    }
    for(int i = 0; i < 5;i++)
    {
        if(bullets3[i].b_free == 1)
        {
            bullets3[i].b_free = 0;
            //子弹位置
            bullets3[i].b_x = x + b_Rect.width()*0.5 -30;
            bullets3[i].b_y = y + b_Rect.height();
            break;
        }
    }
}

void boss::setposition(int x, int y)
{
    this->x = x;
    this->y = y;
    b_Rect.moveTo(x , y);
}
